package iscript.coreFramework.util
{
	public class VectorHelper
	{
		public function VectorHelper()
		{		
		}
		
		private static var keyName:String=""; 
		
		public static function autoSortData(key:String):Function{
		       keyName = key;
			   return _sortData;			
		}
		
		private static function _sortData(x:*, y:*):Number
		{
			var lastNameSort:Number = sortStrings(x[keyName], y[keyName]);
			if (lastNameSort != 0)
			{
				return lastNameSort;
			}
			else
			{
				return sortStrings(x[keyName], y[keyName]);
			}
		}
		
		
		private static function sortStrings(x:*, y:*):Number
		{
			if (x < y)
			{
				return -1;
			}
			else if (x > y)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
	
	    
		public function  HasSameItem(data:*):Boolean{
			var source:*=data;
			var temp:*=data;
			for(var i:int=0;i<source.length;i++){
				if(temp.indexOf(source[i])==-1){
					temp.push(source[i])  
				}else{
					return true;
				}
			}
			source=temp;
			return false;
		}

	
	}
}